//
//  UITextField+StringLength.m
//  JFTwxsd
//
//  Created by Steven on 2018/6/4.
//  Copyright © 2018年 junfeiweiyejiaoyujituan. All rights reserved.
//

#import "UITextField+StringLength.h"
#import <objc/message.h>

@implementation UITextField (StringLength)

- (void)setEmptyBlock:(Empty)emptyBlock{
     objc_setAssociatedObject(self, "UITextField.empty", emptyBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

- (Empty)emptyBlock{
    Empty block = objc_getAssociatedObject(self, "UITextField.empty");
    if (block == nil) {
        block = ^{
            if (self.text.length > 0) {
                return YES;
            }else{
                return NO;
            }
        };
        objc_setAssociatedObject(self, "UITextField.empty", block, OBJC_ASSOCIATION_COPY_NONATOMIC);
    }
    return block;
}

@end

